package com.gatesim;

import java.util.ArrayList;
import java.util.Vector;

import android.content.res.Resources;
import android.gesture.GesturePoint;
import android.gesture.GestureStroke;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

/***
 * A way to key track of Gestsures Generated through on touch handler.
 * @author alemfi
 *
 */
public class GestureTracker {
    private int gID;
    private GestureStroke GS;
    private ArrayList <GesturePoint> GPAL;
    private Paint paint;
    private boolean found;
    
    public GestureTracker(int id){
        this.gID = id;
        GPAL = new ArrayList <GesturePoint> ();
        
        found = false;
        
    //   setGS( new GestureStroke(GPAL) );
        paint = new Paint();
        paint.setStrokeWidth(4);
        switch(this.gID % 5){
        	case 0:
        		paint.setColor(Color.RED);
        		break;
        	case 1:
        		paint.setColor(Color.MAGENTA);
        		break;
        	case 2:
        		paint.setColor(Color.CYAN);
        		break;
        	case 3:
        		paint.setColor(Color.GREEN);
        		break;
        	default:
                paint.setColor(Color.YELLOW);
        		break;
        }
    }

    public ArrayList <GesturePoint> getGPAL() {
        return this.GPAL;
    }

    public void setGPAL(ArrayList <GesturePoint> gPV) {
        this.GPAL = gPV;
    }

    public GestureStroke getGS() {
        return new GestureStroke(GPAL);
    }
    
    public void refreshGS() {
        GS = new GestureStroke(GPAL);
    }
    
    public void draw(Canvas c, Resources r){
    	
    	for(int i = 0; i < GPAL.size()-1 ; i++){
    		c.drawLine(GPAL.get(i).x, GPAL.get(i).y, GPAL.get(i+1).x, GPAL.get(i+1).y, paint);
    	}
    }
    
    public void addGPALPoint(float x, float y, long eventTime){
    	GPAL.add(new GesturePoint(x,y,eventTime));
    }

    public boolean isFound() {
        return found;
    }

    public void setFound() {
        this.found = true;
    }
}

